package com.spic.business.informatization.meeting.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.google.common.collect.Lists;
import com.spic.business.two.tickets.general.domain.AddSafetyPrecautionsSubtable;
import com.spic.business.two.tickets.general.domain.RiskControlMeasuresSubtable;
import com.spic.business.two.tickets.general.domain.SafetyPrecautionsSubtable;
import com.spic.business.two.tickets.general.eum.TableCategoryEnum;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import javax.validation.constraints.NotNull;
import java.util.Collections;
import java.util.List;

@Data
public class MeetingActivityGroupWork {
    /**
     * 主键d
     */
    @TableId(type = IdType.AUTO)
    @NotNull(message = "id不能为空")
    private Long id;

    /**
     * 工会前任务组id
     */
    private Long meetingActivityGroupId;

    /**
     * 工作内容
     */
    private String workContent;

    /**
     * 措施类型
     */
    private String riskType;

    /**
     * 风险措施内容
     */
    private String dataContent;

    public static List<SafetyPrecautionsSubtable> convertToSafetyPrecautionsSubtable(List<MeetingActivityGroupWork> groupWorks, TableCategoryEnum category){
        if(CollectionUtils.isEmpty(groupWorks)) return Collections.EMPTY_LIST;
        List<SafetyPrecautionsSubtable> safetyPrecautionsSubtables = Lists.newArrayListWithCapacity(groupWorks.size());
        for (MeetingActivityGroupWork work : groupWorks) {
            SafetyPrecautionsSubtable safety = new SafetyPrecautionsSubtable();
            safety.setDataContent(work.getDataContent());
            safety.setTableName(category.getCode());
            safetyPrecautionsSubtables.add(safety);
        }
        return safetyPrecautionsSubtables;
    }

    public static List<AddSafetyPrecautionsSubtable> convertToAddSafetyPrecautionsSubtable(List<MeetingActivityGroupWork> groupWorks, TableCategoryEnum category){
        if(CollectionUtils.isEmpty(groupWorks)) return Collections.EMPTY_LIST;
        List<AddSafetyPrecautionsSubtable> addSafetySubtable = Lists.newArrayListWithCapacity(groupWorks.size());
        for (MeetingActivityGroupWork work : groupWorks) {
            AddSafetyPrecautionsSubtable safety = new AddSafetyPrecautionsSubtable();
            safety.setDataContent(work.getDataContent());
            safety.setTableName(category.getCode());
            addSafetySubtable.add(safety);
        }
        return addSafetySubtable;
    }

    public static List<RiskControlMeasuresSubtable> convertToRiskControlMeasuresSubtable(List<MeetingActivityGroupWork> groupWorks, TableCategoryEnum category){
        if(CollectionUtils.isEmpty(groupWorks)) return Collections.EMPTY_LIST;
        List<RiskControlMeasuresSubtable> riskControlSubtables = Lists.newArrayListWithCapacity(groupWorks.size());
        for (MeetingActivityGroupWork work : groupWorks) {
            RiskControlMeasuresSubtable safety = new RiskControlMeasuresSubtable();
            safety.setDataContent(work.getDataContent());
            safety.setTableName(category.getCode());
            riskControlSubtables.add(safety);
        }
        return riskControlSubtables;
    }
}

